<script setup lang='ts'>
  import { computed } from 'vue';
  import xmdialog from '@/components/xmdialog.vue';
  import { getAssetsFile, xmloading } from '@/utils/public';
  import { userStore } from '@/pinia/modules/user';
  const useUserStore = userStore()
  import { diamond_balance } from '@/pinia/getter'
  const $emit = defineEmits(['update:dialogshow','change'])
  const props = defineProps({
    dialogshow:{
      type:Boolean,
      default:false
    },
    page:{
      type:String,
      default:'appbanner'
    }
  })
  const show = computed({
    set:(val)=>{
      if(!val) handleConfirm()
    },
    get:()=>{
      return props.dialogshow
    }
  })
  const handleConfirm = async(type:any = 0)=>{
    if(type == 2) {
      const loading = xmloading()
      await useUserStore.userSet({
        type:1,
        val:1
      })
      loading.close()
    }
    $emit('update:dialogshow',false)
    $emit('change')
  }
</script>

<template>
  <xmdialog class="newDialogBack" v-model:dialogshow="show">
    <template v-slot:titleImg>
      <img :src="getAssetsFile('titleimg8.png')">
    </template>
    <div class="borderColor">
      <template v-if="page != 'handletips'">
        <div class="tipsTitle flex-align-center">
          <img src="@/assets/images/icon5.png">
          <span style="margin-right: 8px;">=</span>
          <span>100</span>
          <img src="@/assets/images/icon2.png">
        </div>
        <div v-if="page == 'h5Rule'" class="font tipsDialog">
          1狩猎券等于100钻石，在狩猎券不足时，<br>
          将自动扣除对应钻石数，<br>
          狩猎券可前往背包内查看或送出。<br>
        </div>
      </template>
      <template v-if="page == 'handletips'">
        <div class="font">
          参与森林狩猎需要用狩猎券，<br>
          开启钻石兑换狩猎券可以更便捷的游戏，<br>
          1张狩猎券=100钻石，<br>
          您的钻石余额：{{ diamond_balance }}
        </div>
        <ul class="butList flex-align-center">
          <li @click="handleConfirm(1)">
            <img :src="getAssetsFile('textImg1.png')" >
          </li>
          <li @click="handleConfirm(2)">
            <img :src="getAssetsFile('textImg2.png')" >
          </li>
        </ul>
      </template>
    </div>
  </xmdialog>
</template>

<style lang='scss' scoped>
  .newDialogBack {
    .borderColor {
      width: 315px;
      height: 180px;
      height: max-content;
      padding: 11px 0;
      box-sizing: border-box;
      .tipsTitle {
        margin: 0 0 10px 0;
        span {
          color: #fff;
          font-size: 20px;
        }
        img {
          width: 25px;
          height: 25px;
        }
        img:nth-child(1) {
          margin-right: 10px;
        }
        img:nth-child(4) {
          margin-left: 4px;
        }
      }
      .tipsDialog {
        padding:9px 0 13px;
      }
      .font {
        line-height: 22px;
        color: #fff;
        font-size: 14px;
        font-weight: 500;
        text-align: center;
      }
      .butList {
        margin: 15px 0 0;
        li {
          width: 130px;
          height: 42px;
          border-radius: 21px;
          display: flex;
          align-items: center;
          justify-content: center;
          img {
            width: auto;
          }
        }
        li:nth-child(1) {
          margin-right: 10px;
          background: linear-gradient(180deg, #FF911F 0%, #FF580E 100%);
          box-shadow: inset 0px -2px 0px 0px rgba(157,0,0,0.5), inset 0px 2px 0px 0px rgba(255,255,255,0.4);
          img {
            height: 16px;
          }
        }
        li:nth-child(2) {
          background: linear-gradient(180deg, #FFE21F 0%, #FFC00E 100%);
          box-shadow: inset 0px 2px 0px 0px rgba(255,255,255,0.7), inset 0px -2px 0px 0px rgba(157,0,0,0.5);
          img {
            height: 17px;
          }
        }
      }
    }
  }
</style>